package main

import "fmt"

func main() {

	var us [2]Usb = [2]Usb{}
	us[0] = Phone{Name: "手机"}
	us[1] = Camera{Name: "相机"}

	for _, usb := range us {
		usb.Start()
		p, ok := usb.(Phone)
		if ok {
			p.call()
		} else {
			fmt.Printf("类型 %T：不是手机，没有call", usb)
		}

	}
}

type Usb interface {
	Start()
}

type Phone struct {
	Name string
}
type Camera struct {
	Name string
}

func (c Camera) Start() {
	fmt.Println(c.Name, "start....")

}

func (c Phone) Start() {
	fmt.Println(c.Name, "start....")
}
func (c Phone) call() {
	fmt.Println(c.Name, "打电话....")
}
